home *** CD-ROM | disk | FTP | other *** search
Wrap
/******************************************************************** * FinderXDA * * Written by Bob Haven based on TestDA written By John Selhorst * *********************************************************************/ #include <memory.h> #include <GSOS.h> #include <loader.h> #include <setjmp.h> #include <stdio.h> #include <misctool.h> #include <locator.h> #include <finder.h> #include <resources.h> #include <IntMath.h> #include <quickdraw.h> #include <menu.h> #include <window.h> #include <desk.h> #include <strings.h> #include <TextEdit.h> #include <font.h> #include "rDefs.h" /************************************************************************************************/ extern void AsmProc(); extern char beginDA[]; extern int _toolErr; /* Here's the controls for the main window */ extern StaticTextTemplate PathnameStatText; extern TextEditTemplate PathnameTextEdit; extern PopupTemplate AcceptRequestsPopUp; extern PopupTemplate SendRequestsPopUp; extern PopupTemplate tellFinderMItemSelectedPopUp; extern MenuItemTemplate tellFinderAddToExtrasMenuItem; extern CheckBoxTemplate HiliteBitCheckBox; extern CheckBoxTemplate HandleItFlagCheckBox; extern CheckBoxTemplate DeselectIconsCheckBox; extern CheckBoxTemplate ExtendedIconsCheckBox; extern StaticTextTemplate ColorValueStatText; extern TextEditTemplate ColorValueTextEdit; extern SimpleButtonTemplate SetIconColorButton; extern SimpleButtonTemplate helpButton; extern TextEditTemplate MyWindCtl; /* Here's the controls for the tellFInderMatchFileToIcon window */ extern SimpleButtonTemplate MatchButton; extern StaticTextTemplate VotingBitsStatText; extern TextEditTemplate VotingBitsTextEdit; extern StaticTextTemplate MatchWhichStatText; extern TextEditTemplate MatchWhichTextEdit; extern StaticTextTemplate FileTypeStatText; extern TextEditTemplate FileTypeTextEdit; extern StaticTextTemplate AuxTypeStatText; extern TextEditTemplate AuxTypeTextEdit; extern StaticTextTemplate FilenameStatText; extern TextEditTemplate FilenameTextEdit; extern StaticTextTemplate CreateDateStatText; extern TextEditTemplate CreateDateTextEdit; extern StaticTextTemplate ModDateStatText; extern TextEditTemplate ModDateTextEdit; extern StaticTextTemplate AccessStatText; extern TextEditTemplate AccessTextEdit; extern StaticTextTemplate FlagsStatText; extern TextEditTemplate FlagsTextEdit; extern StaticTextTemplate EOFStatText; extern TextEditTemplate EOFTextEdit; /************************************************************************************************/ /* Most of the Globals are here */ static word myID; static word NDA_ID; static unsigned int FinderMemoryID; static Boolean FMStarted = 0; static Boolean TEStarted = 0; static Handle FMZeroPageHndl; static Handle TEZeroPageHndl; char finderTarget[] = NAME_OF_FINDER; int OpenFlag = 0; /* flag to indicate if the main window is open */ int quitflag = 0; /* set to 1 by action routine if its time to quit */ int finderSaysIdleFlag = 0; /* used to limit the number of finderSaysIdle requests */ Rect IdleRect; NDASysWindRecord FinderXDANDASysWindRec; NDASysWindRecord DebugInfoNDASysWindRec; NDASysWindRecord GetSelectedIconsNDASysWindRec; NDASysWindRecord GetWindowIconsNDASysWindRec; NDASysWindRecord HelpNDASysWindRec; NDASysWindRecord MatchNDASysWindRec; AuxWindInfoPtr DebugInfoAuxWindRecPtr; AuxWindInfoPtr GetSelectedIconsAuxWindRecPtr; AuxWindInfoPtr GetWindowIconsAuxWindRecPtr; AuxWindInfoPtr HelpAuxWindRecPtr; AuxWindInfoPtr MatchAuxWindRecPtr; GrafPortPtr FinderXDAWindPtr = 0; /* Window pointer for DA window */ GrafPortPtr DebugInfoWindPtr = 0; /* Window pointer for tellFinderGetDebugInfo window */ GrafPortPtr GetSelectedIconsWindPtr = 0; /* Window pointer for tellFinderGetSelectedIcons window */ GrafPortPtr GetWindowIconsWindPtr = 0; /* Window pointer for tellFinderGetWindowIcons window */ GrafPortPtr HelpWindPtr = 0; /* Window pointer for Help window */ GrafPortPtr MatchWindPtr = 0; /* Window pointer for tellFinderMatchFileToIcons window */ CtlRecHndl HelpCtlHandle; CtlRecHndl MatchCtlHandle; tellFinderGetSelectedIconsOut tellFinderGetSelectedIconsOutput; /* this is global because I pass him to tellFinderSetSelectedIconsProc */ static char AlertString[400]; /* used for all AlertWindow calls */ static char ErrorString[128]; /* is passed back from my generic error checking routine */ #define MAXNUMMENUITEMS 16 /* Constant for the max num of menuitems allowed by this tool */ static word menuItemID[MAXNUMMENUITEMS]; /* Global array to hold ID's of added/deleted menu items */ int menuItemIndex = 0; /* Array index to pass to add and delete procs */ /************************************************************************************************/ /* A control update proc used by all the windows */ static void UpdateControls() { DrawControls(GetPort()); } /* Control list for the main window */ static Pointer FinderXDACtlList[] = { (Pointer)&helpButton, (Pointer)&SetIconColorButton, (Pointer)&ColorValueStatText, (Pointer)&HandleItFlagCheckBox, (Pointer)&HiliteBitCheckBox, (Pointer)&DeselectIconsCheckBox, (Pointer)&ExtendedIconsCheckBox, (Pointer)&tellFinderMItemSelectedPopUp, (Pointer)&SendRequestsPopUp, (Pointer)&AcceptRequestsPopUp, (Pointer)&PathnameTextEdit, (Pointer)&ColorValueTextEdit, (Pointer)&PathnameStatText, NULL }; /************************************************************************************************/ /* Main window wind parmam list and color table (color table used by other windows */ WindColor WindowColorTable[5] = { 0x0000,0x0f10,0x001e,0x4004,0x0000 }; static ParamList FinderXDAWindParams = { sizeof(FinderXDAWindParams), 0xc2a8, "\pFinderXDA", NULL, 0,0,0,0, WindowColorTable, 0,0, 200,640, 200,640, 4,16, 40,160, 0L, 0, NULL, NULL, UpdateControls, 25,96,187,546, (GrafPortPtr) -1L, NULL}; /************************************************************************************************/ /* Param list for the tellFinderGetDebugInfo window */ static ParamList DebugInfoWindParams = { sizeof(DebugInfoWindParams), 0xc2a8, "\ptellFinderGetDebugInfo Window", NULL, 0,0,0,0, WindowColorTable, /* We use the DA window color table */ 0,0, 200,640, 200,640, 4,16, 40,160, 0L, 0, NULL, NULL, UpdateControls, 25,40,182,600, (GrafPortPtr) -1L, NULL}; /************************************************************************************************/ /* Param list for the tellFinderGetSelectedIcons window */ static ParamList GetSelectedIconsWindParams = { sizeof(GetSelectedIconsWindParams), 0xc2a8, "\ptellFinderGetSelectedIcons Pathnames Window", NULL, 0,0,0,0, WindowColorTable, 0,0, 200,640, 200,640, 4,16, 40,160, 0L, 0, NULL, NULL, UpdateControls, 25,40,182,600, (GrafPortPtr) -1L, NULL}; /************************************************************************************************/ /* Param list for the tellFinderGetWindowIcons window */ static ParamList GetWindowIconsWindParams = { sizeof(GetWindowIconsWindParams), 0xc2a8, "\ptellFinderGetWindowIcons Pathnames Window", NULL, 0,0,0,0, WindowColorTable, 0,0, 200,640, 200,640, 4,16, 40,160, 0L, 0, NULL, NULL, UpdateControls, 25,40,182,600, (GrafPortPtr) -1L, NULL}; /************************************************************************************************/ /* Param list for the Help window */ static ParamList HelpWindParams = { sizeof(HelpWindParams), 0xc2a8, "\pHelp Window", NULL, 0,0,0,0, WindowColorTable, /* We use the DA window color table */ 0,0, 200,640, 200,640, 4,16, 40,160, 0L, 0, NULL, NULL, UpdateControls, 25,40,182,600, (GrafPortPtr) -1L, NULL}; /************************************************************************************************/ /* Param list and control list for the tellFinderMatchFileToIcon window */ static Pointer MatchCtlList[] = { (Pointer)&MatchButton, (Pointer)&EOFTextEdit, (Pointer)&EOFStatText, (Pointer)&FlagsTextEdit, (Pointer)&FlagsStatText, (Pointer)&AccessTextEdit, (Pointer)&AccessStatText, (Pointer)&ModDateTextEdit, (Pointer)&ModDateStatText, (Pointer)&CreateDateTextEdit, (Pointer)&CreateDateStatText, (Pointer)&FilenameTextEdit, (Pointer)&FilenameStatText, (Pointer)&AuxTypeTextEdit, (Pointer)&AuxTypeStatText, (Pointer)&FileTypeTextEdit, (Pointer)&FileTypeStatText, (Pointer)&MatchWhichTextEdit, (Pointer)&MatchWhichStatText, (Pointer)&VotingBitsTextEdit, (Pointer)&VotingBitsStatText, NULL }; static ParamList MatchWindParams = { sizeof(MatchWindParams), 0xc2a8, "\ptellFinderMatchFileToIcons Window", NULL, 0,0,0,0, WindowColorTable, 0,0, 200,640, 200,640, 4,16, 40,160, 0L, 0, NULL, NULL, UpdateControls, 25,40,190,600, (GrafPortPtr) -1L, NULL}; /************************************************************************************************/ /* Here's a routine I use to find the next visible window and return the windowptr to the caller */ GrafPortPtr findNextVisWindow() { GrafPortPtr whichWindow = FrontWindow(); while (whichWindow != NIL) { whichWindow = GetNextWindow(whichWindow); if(whichWindow == NIL) break; if (GetSysWFlag(whichWindow)) continue; if(GetWFrame (whichWindow) & fVis) break; } return whichWindow; } /************************************************************************************************/ pascal void CloseFinderXDA(); /* Predeclared for use by the following functions */ /* A bunch of functions to setup data structs required when creating windows from your DA */ SetUpDebugInfoNDASysWindRec() { DebugInfoNDASysWindRec.status = 0; DebugInfoNDASysWindRec.openProc = 0; DebugInfoNDASysWindRec.closeProc = (ProcPtr)CloseFinderXDA; DebugInfoNDASysWindRec.actionProc = (ProcPtr)AsmProc; DebugInfoNDASysWindRec.initProc = 0; DebugInfoNDASysWindRec.period = 0; DebugInfoNDASysWindRec.eventMask = everyEvent; DebugInfoNDASysWindRec.lastServiced = 0; DebugInfoNDASysWindRec.windowPtr = 0; DebugInfoNDASysWindRec.ndaHandle = 0; DebugInfoNDASysWindRec.memoryID = myID; } SetUpGetSelectedIconsNDASysWindRec() { GetSelectedIconsNDASysWindRec.status = 0; GetSelectedIconsNDASysWindRec.openProc = 0; GetSelectedIconsNDASysWindRec.closeProc = (ProcPtr)CloseFinderXDA; GetSelectedIconsNDASysWindRec.actionProc = (ProcPtr)AsmProc; GetSelectedIconsNDASysWindRec.initProc = 0; GetSelectedIconsNDASysWindRec.period = 0; GetSelectedIconsNDASysWindRec.eventMask = everyEvent; GetSelectedIconsNDASysWindRec.lastServiced = 0; GetSelectedIconsNDASysWindRec.windowPtr = 0; GetSelectedIconsNDASysWindRec.ndaHandle = 0; GetSelectedIconsNDASysWindRec.memoryID = myID; } SetUpGetWindowIconsNDASysWindRec() { GetWindowIconsNDASysWindRec.status = 0; GetWindowIconsNDASysWindRec.openProc = 0; GetWindowIconsNDASysWindRec.closeProc = (ProcPtr)CloseFinderXDA; GetWindowIconsNDASysWindRec.actionProc = (ProcPtr)AsmProc; GetWindowIconsNDASysWindRec.initProc = 0; GetWindowIconsNDASysWindRec.period = 0; GetWindowIconsNDASysWindRec.eventMask = everyEvent; GetWindowIconsNDASysWindRec.lastServiced = 0; GetWindowIconsNDASysWindRec.windowPtr = 0; GetWindowIconsNDASysWindRec.ndaHandle = 0; GetWindowIconsNDASysWindRec.memoryID = myID; } SetUpHelpNDASysWindRec() { HelpNDASysWindRec.status = 0; HelpNDASysWindRec.openProc = 0; HelpNDASysWindRec.closeProc = (ProcPtr)CloseFinderXDA; HelpNDASysWindRec.actionProc = (ProcPtr)AsmProc; HelpNDASysWindRec.initProc = 0; HelpNDASysWindRec.period = 0; HelpNDASysWindRec.eventMask = everyEvent; HelpNDASysWindRec.lastServiced = 0; HelpNDASysWindRec.windowPtr = 0; HelpNDASysWindRec.ndaHandle = 0; HelpNDASysWindRec.memoryID = myID; } SetUpMatchNDASysWindRec() { MatchNDASysWindRec.status = 0; MatchNDASysWindRec.openProc = 0; MatchNDASysWindRec.closeProc = (ProcPtr)CloseFinderXDA; MatchNDASysWindRec.actionProc = (ProcPtr)AsmProc; MatchNDASysWindRec.initProc = 0; MatchNDASysWindRec.period = 0; MatchNDASysWindRec.eventMask = everyEvent; MatchNDASysWindRec.lastServiced = 0; MatchNDASysWindRec.windowPtr = 0; MatchNDASysWindRec.ndaHandle = 0; MatchNDASysWindRec.memoryID = myID; } /************************************************************************************************/ /* This is my generic error checking routine. It takes the _toolErr and Display flag as input params. */ /* It converts the _toolErr number into a string which is a global. The string is displayed in an */\ /* AlertWindow depending on the value of the flag param. */ CheckError(ErrorNum,DisplayFlag) word ErrorNum; word DisplayFlag; /* 1 = Display AlertWindow, != 1 don't show, and return ErrorString */ { strcpy (ErrorString,"Unknown error"); /* Initialize error string if we don't know the error number */ switch(ErrorNum) { case 0x0000: strcpy(ErrorString,"No error"); break; /* Finder errors */ case 0x4201: strcpy(ErrorString,"Finder - bad input value"); break; case 0x4202: strcpy(ErrorString,"Finder - could not complete request"); break; case 0x4203: strcpy(ErrorString,"Finder - user cancelled operation"); break; case 0x4204: strcpy(ErrorString,"Finder - menu item was dimmed"); break; case 0x4205: strcpy(ErrorString,"Finder - not now, Finder has a headache"); break; case 0x4206: strcpy(ErrorString,"Finder - can't add Finder's resources to desktop file"); break; case 0x4207: strcpy(ErrorString,"Finder - unknown rBundle version, or rBundle damaged"); break; case 0x42FF: strcpy(ErrorString,"Finder - request not implemented"); break; /* GS/OS errors */ case 0x0027: strcpy(ErrorString,"GSOS - I/O error"); break; case 0x0028: strcpy(ErrorString,"GSOS - no device connected"); break; case 0x002E: strcpy(ErrorString,"GSOS - disk switched"); break; case 0x0040: strcpy(ErrorString,"GSOS - invalid pathname syntax"); break; case 0x0044: strcpy(ErrorString,"GSOS - path not found"); break; case 0x0045: strcpy(ErrorString,"GSOS - volume not found"); break; case 0x0046: strcpy(ErrorString,"GSOS - file not found"); break; case 0x004A: strcpy(ErrorString,"GSOS - version error"); break; case 0x004E: strcpy(ErrorString,"GSOS - access not allowed"); break; case 0x004F: strcpy(ErrorString,"GSOS - buffer too small"); break; case 0x0050: strcpy(ErrorString,"GSOS - file open"); break; case 0x0052: strcpy(ErrorString,"GSOS - unsupported volume type"); break; case 0x0058: strcpy(ErrorString,"GSOS - not a block device"); break; case 0x0059: strcpy(ErrorString,"GSOS - invalid file level"); break; case 0x005c: strcpy(ErrorString,"GSOS - not an application"); break; /* Loader Errors */ case 0x1101: strcpy(ErrorString,"Loader - entry not found"); break; case 0x1103: strcpy(ErrorString,"Loader - pathname error"); break; /* Desk Manager Errors */ case 0x0510: strcpy(ErrorString,"Desk Manager - specified NDA not available"); break; case 0x0511: strcpy(ErrorString,"Desk Manager - not pointer to a System window"); break; /* Tool Locator Errors */ case 0x0001: strcpy(ErrorString,"Tool Locator - tool not found"); break; case 0x0110: strcpy(ErrorString,"Tool Locator - tool specified minimum version not found"); break; /* TextEdit Errors */ case 0x2201: strcpy(ErrorString,"TextEdit already started"); break; case 0x220D: strcpy(ErrorString,"TextEdit - the Font Manager was not started"); break; case 0x2202: strcpy(ErrorString,"TextEdit - TextEdit not started"); break; case 0x2203: strcpy(ErrorString,"TextEdit - the teH parameter does not refer to a valid TERecord"); break; case 0x2204: strcpy(ErrorString,"TextEdit - invalid text descriptor value specified"); break; case 0x2208: strcpy(ErrorString,"TextEdit - TE buffer overflow"); break; case 0x220C: strcpy(ErrorString,"TextEdit - LETextBox2 format codes were inconsistent"); break; /* Font Manager Errors */ case 0x1B01: strcpy(ErrorString,"Font Manager - duplicate FMStartUp call"); break; case 0x1B03: strcpy(ErrorString,"Font Manager - Font Manager not active"); break; /* Control Manager Errors */ case 0x1004: strcpy(ErrorString,"Control Manager - no controls in window"); break; case 0x1005: strcpy(ErrorString,"Control Manager - no extended controls in window"); break; case 0x1009: strcpy(ErrorString,"Control Manager - the specified control ID cannot be found"); break; case 0x100C: strcpy(ErrorString,"Control Manager - no FrontWindow to make call on"); break; /* Memory Manager Errors */ case 0x0201: strcpy(ErrorString,"Memory Manager - unable to allocate block"); break; case 0x0204: strcpy(ErrorString,"Memory Manager - illegal operation on a locked or immovable block"); break; case 0x0206: strcpy(ErrorString,"Memory Manager - invalid handle"); break; case 0x0207: strcpy(ErrorString,"Memory Manager - invalid user ID"); break; /* Integer Math errors */ case 0x0B02: strcpy(ErrorString,"Integer Math - illegal character in string"); break; case 0x0B03: strcpy(ErrorString,"Integer Math - hex value is greater than $FFFFFFFF"); break; case 0x0B04: strcpy(ErrorString,"Integer Math - string too short to represent value"); break; /* Resource Manager errors */ case 0x1E04: strcpy(ErrorString,"Resource Manager - no current open resource files"); break; case 0x1E06: strcpy(ErrorString,"Resource Manager - specified resource not found"); break; case 0x1E08: strcpy(ErrorString,"Resource Manager - user ID not found"); break; case 0x1E09: strcpy(ErrorString,"Resource Manager - no more resource IDs available"); break; case 0x1E10: strcpy(ErrorString,"Resource Manager - no resource with geven name"); break; case 0x1E12: strcpy(ErrorString,"Resource Manager - already started with this ID"); break; case 0x1E0B: strcpy(ErrorString,"Resource Manager - resource file is already open"); break; } sprintf(AlertString,"42/Error = $%x\r%s/^OK", /* setup the string for AlertWindow */ ErrorNum, ErrorString); if (DisplayFlag == 1) /* call AlertWindow if flag = 1 */ { AlertWindow (0x0000,NULL,AlertString); } } /************************************************************************************************/ /* This is called by the DA Close Proc to close other windows opened by this DA */ void CloseIfOpen(PtrToWind) GrafPortPtr *PtrToWind; { if(*PtrToWind!=NIL) { CloseWindow(*PtrToWind); *PtrToWind = NIL; } } /************************************************************************************************/ /* This routine is called by the tellFinderMatchFileToIconProc. It Sets up DataIn and calls to SendReqest. */ DoTheMatchProc() { tellFinderMatchFileToIconOut tellFinderMatchFileToIconOutput; tellFinderMatchFileToIconIn tellFinderMatchFileToIconInput; char votingBitsString[4]; char whichMatchString[4]; char filetypeString[4]; char auxtypeString[8]; ptr filenameToMatchPtr; char createFileInfoPtrString[8]; char modFileInfoPtrString[8]; char localAccessString[4]; char flagsString[4]; char combinedEOFString[8]; int errorFlag = 0; word ButtonSelected; long textLength; tellFinderMatchFileToIconInput.pCount = 11; /* I get the text from all the controls, convert them, and then stuff them into the DataIn struc */ /* to be passed in SendRequest. I do some error checking for right number of chars and values. The */ /* first param on TEGetText determines the format of the text. */ if ((textLength = TEGetText (0x0005,votingBitsString,4L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002002L))) < 4) { AlertWindow (0x0000,NULL,"32/Too few characters in votingBitsString string./^OK"); errorFlag = 1; } else { tellFinderMatchFileToIconInput.votingBits = (word)Hex2Int(votingBitsString,4); if(_toolErr) { CheckError(_toolErr,0x0001); errorFlag = 1; } } if ((textLength = TEGetText (0x0005,whichMatchString,4L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002004L))) < 4) { AlertWindow (0x0000,NULL,"32/Too few characters in whichMatchString string./^OK"); errorFlag = 1; } else { tellFinderMatchFileToIconInput.whichMatch = (word)Hex2Long(whichMatchString,4); if(_toolErr) { CheckError(_toolErr,0x0001); errorFlag = 1; } } if ((textLength = TEGetText (0x0005,filetypeString,4L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002006L))) < 4) { AlertWindow (0x0000,NULL,"32/Too few characters in filetypeString string./^OK"); errorFlag = 1; } else { tellFinderMatchFileToIconInput.filetype = (word)Hex2Long(filetypeString,4); if(_toolErr) { CheckError(_toolErr,0x0001); errorFlag = 1; } } if ((textLength = TEGetText (0x0005,auxtypeString,8L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002008L))) < 8) { AlertWindow (0x0000,NULL,"32/Too few characters in auxtypeString string./^OK"); errorFlag = 1; } else { tellFinderMatchFileToIconInput.auxtype = (long)Hex2Long(auxtypeString,8); if(_toolErr) { CheckError(_toolErr,0x0001); errorFlag = 1; } } TEGetText (0x0000,filenameToMatchPtr,0x000000ffL,0x0000,0L,GetCtlHandleFromID(NIL,0x0000200AL)); if(_toolErr) { CheckError(_toolErr,0x0001); errorFlag = 1; } else tellFinderMatchFileToIconInput.matchFilenamePtr = filenameToMatchPtr; if ((textLength = TEGetText (0x0005,createFileInfoPtrString,8L,0x0000,0L,GetCtlHandleFromID(NIL,0x0000200CL))) < 8) { AlertWindow (0x0000,NULL,"32/Too few characters in createFileInfoPtrString string./^OK"); errorFlag = 1; } else { tellFinderMatchFileToIconInput.createFileInfoPtr = (Ptr)Hex2Long(createFileInfoPtrString,8); if(_toolErr) { CheckError(_toolErr,0x0001); errorFlag = 1; } } if ((textLength = TEGetText (0x0005,modFileInfoPtrString,8L,0x0000,0L,GetCtlHandleFromID(NIL,0x0000200EL))) < 8) { AlertWindow (0x0000,NULL,"32/Too few characters in modFileInfoPtrString string./^OK"); errorFlag = 1; } else { tellFinderMatchFileToIconInput.modFileInfoPtr = (Ptr)Hex2Long(modFileInfoPtrString,8); if(_toolErr) { CheckError(_toolErr,0x0001); errorFlag = 1; } } if ((textLength = TEGetText (0x0005,localAccessString,4L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002010L))) < 4) { AlertWindow (0x0000,NULL,"32/Too few characters in localAccessString string./^OK"); errorFlag = 1; } else { tellFinderMatchFileToIconInput.localAccess = (word)Hex2Long(localAccessString,4); if(_toolErr) { CheckError(_toolErr,0x0001); errorFlag = 1; } } if ((textLength = TEGetText (0x0005,flagsString,4L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002012L))) < 4) { AlertWindow (0x0000,NULL,"32/Too few characters in flagsString string./^OK"); errorFlag = 1; } else { tellFinderMatchFileToIconInput.flags = (word)Hex2Long(flagsString,4); if(_toolErr) { CheckError(_toolErr,0x0001); errorFlag = 1; } } tellFinderMatchFileToIconInput.optionListPtr = NIL; if ((textLength = TEGetText (0x0005,combinedEOFString,8L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002014L))) < 8) { AlertWindow (0x0000,NULL,"32/Too few characters in combinedEOFString string./^OK"); errorFlag = 1; } else { tellFinderMatchFileToIconInput.combinedEOF = (long)Hex2Long(combinedEOFString,8); if(_toolErr) { CheckError(_toolErr,0x0001); errorFlag = 1; } } /* If I didn't get any errors from above, I call SendRequest and AlertWindow to display DataOut from SendRequest */ if (errorFlag == 0) { SendRequest (tellFinderGetDebugInfo,0x8001,finderTarget,&tellFinderMatchFileToIconInput,&tellFinderMatchFileToIconOutput); sprintf(AlertString,"90/recvCount = $%x\rfinderResult = $%x\roneDocOffset = $%lxL\rrBundleHandle = $%lxL\rsmallIconHandle = $%lxL\rlargeIconHandle = $%lxL\rrFinderPathHandle = $%lxL/^OK", tellFinderMatchFileToIconOutput.recvCount, tellFinderMatchFileToIconOutput.finderResult, tellFinderMatchFileToIconOutput.oneDocOffset, tellFinderMatchFileToIconOutput.rBundleHandle, tellFinderMatchFileToIconOutput.smallIconHandle, tellFinderMatchFileToIconOutput.largeIconHandle, tellFinderMatchFileToIconOutput.rFInderPathHandle); /* sprintf(AlertString,"90/pCount = $%x\tvotingBits = $%x\twhichMatch = $%xrfiletype = $%x\tauxtype = $%lxL\rmatchFilenamePtr = $%lxL\rcreateFileInfoPtr = $%lxL\rmodFileInfoPtr = $%lxL\rlocalAccess = $%x\tflags = $%x\roptionListPtr = $%lxL\rcombinedEOF = $%lxL/^OK", tellFinderMatchFileToIconInput.pCount, tellFinderMatchFileToIconInput.votingBits, tellFinderMatchFileToIconInput.whichMatch, tellFinderMatchFileToIconInput.filetype, tellFinderMatchFileToIconInput.auxtype, tellFinderMatchFileToIconInput.matchFilenamePtr, tellFinderMatchFileToIconInput.createFileInfoPtr, tellFinderMatchFileToIconInput.modFileInfoPtr, tellFinderMatchFileToIconInput.localAccess, tellFinderMatchFileToIconInput.flags, tellFinderMatchFileToIconInput.optionListPtr, tellFinderMatchFileToIconInput.combinedEOF); */ AlertWindow (0x0000,NULL,AlertString); } } /************************************************************************************************/ /* A routine to see if the menu item ID from finderSaysExtrasChoosen belongs to me. If so I */ /* handle it. If not, I exit */ int ItemBelongsToMe(MenuItemID) word MenuItemID; { int i; for (i = 0; i < menuItemIndex; ++i) { if(MenuItemID == menuItemID[i]) return 1; } return 0; } /************************************************************************************************/ /* All the stuff needed for all the AcceptRequests follows */ /* Define a union for the finderSays input buffer types */ typedef union { finderSaysHelloIn finderSaysHelloInputBuffer; finderSaysMItemSelectedIn finderSaysMItemSelectedInputBuffer; finderSaysBeforeOpenIn finderSaysBeforeOpenInputBuffer; finderSaysOpenFailedIn finderSaysOpenFailedInputBuffer; finderSaysBeforeCopyIn finderSaysBeforeCopyInputBuffer; finderSaysBeforeRenameIn finderSaysBeforeRenameInputBuffer; finderSaysKeyHitIn finderSaysKeyHitInputBuffer; } AcceptRequestDataIn; typedef struct MyMytellFinderGetDebugInfoOut { word recvCount; word finderResult; word pCount; word directPage; handle deskIcon; handle nameChainH; pointer filetypeBlock; pointer deviceBlock; handle masterChainH; handle rFPListHandle; word rFPCount; long reserved1; /* nameChainInsert */ long reserved2; long reserved3; /* masterChainInsert */ long reserved4; handle chainTable; handle iconOffsetArray; handle iconHandleArray; word iconArrayUsed; word iconArraySize; long reserved5; char reserved[60]; } MytellFinderGetDebugInfoOut, *MytellFinderGetDebugInfoOutPtr; /* Define my Request Procedures which are called by the various AcceptRequests Procs */ /* This one handles the finderSaysExtrasChosen request */ int finderSaysExtrasChosenProc (DataIn) long DataIn; { if (ItemBelongsToMe((word)DataIn)) /* Check to see if the extras menu item is one that I created. If it is, handle it. */ { InitCursor (); sprintf(AlertString,"40/Request Code = finderSaysExtrasChoosen\rMenu Item ID = $%x/^OK", DataIn); AlertWindow (0x0000,NULL,AlertString); return 1; } return 0; } /* This one handles the finderSaysMItemSelected request */ finderSaysMItemSelectedProc(DataIn) AcceptRequestDataIn *DataIn; { InitCursor (); sprintf(AlertString,"40/Request Code = finderSaysMItemSelected\rMenu Item ID = $%x\rMenu ID = $%x\rModifiers = $%x/^OK", DataIn -> finderSaysMItemSelectedInputBuffer.menuItemID, DataIn -> finderSaysMItemSelectedInputBuffer.menuID, DataIn -> finderSaysMItemSelectedInputBuffer.modifiers); AlertWindow(0x0000,NULL,AlertString); } /* PatchFinder60 (called with the dataIn value from finderSaysHello) Patches Finder 6.0 as specified in the Finder 6.0 documentation, to allow us to call tellFinderGetSelectedIcons (extended) and tellFinderGetWindowIcons (extended). by David A. Lyons, 25-Feb-92 */ void PatchFinder60(dataIn) finderSaysHelloInPtr dataIn; { Handle mainSeg; char *main; if( dataIn->versNum == 0x0600A000) { mainSeg = FindHandle(dataIn); main = (char *) *mainSeg; *(unsigned *)(main+0x2E5A) = 0x0AA0; *(unsigned *)(main+0x2E5C) = 0x8000; *(unsigned *)(main+0x2E5E) = 0x003F; } } pascal int InitHelloRequestProc(Request,DataIn,DataOut) unsigned Request; AcceptRequestDataIn *DataIn; long DataOut; { unsigned oldDB = SaveDB(); if (Request == finderSaysHello) { PatchFinder60(DataIn); RestoreDB(oldDB); return (0x8000); } RestoreDB(oldDB); return (0x0000); } /* This proc handles the finderSaysHello request */ pascal int HelloRequestProc(Request,DataIn,DataOut) unsigned Request; AcceptRequestDataIn *DataIn; long DataOut; { unsigned oldDB = SaveDB(); if (Request == finderSaysHello) { InitCursor (); sprintf(AlertString,"40/Request Code = finderSaysHello\rFinder Version = $%lxL\rFinder ID = $%x\rIcon Object Size = $%x/^OK", DataIn -> finderSaysHelloInputBuffer.versNum, DataIn -> finderSaysHelloInputBuffer.finderUserID, DataIn -> finderSaysHelloInputBuffer.iconObjectSize); AlertWindow (0x0000,NULL,AlertString); FinderMemoryID = DataIn -> finderSaysHelloInputBuffer.finderUserID; RestoreDB(oldDB); return (0x8000); } RestoreDB(oldDB); return (0x0000); } /* This proc handles the finderSaysGoodbye request */ pascal int GoodbyeRequestProc(Request,DataIn,DataOut) unsigned Request; AcceptRequestDataIn *DataIn; long DataOut; { unsigned oldDB = SaveDB(); if (Request == finderSaysGoodbye) { InitCursor (); AlertWindow (0x0000,NULL,"40/Request Code = finderSaysGoodbye\rDataIn and DataOut are reserved./^OK"); RestoreDB(oldDB); return (0x8000); } RestoreDB(oldDB); return (0x0000); } /* This proc handles the finderSaysSelectionChanged request */ pascal int SelectionChangedRequestProc(Request,DataIn,DataOut) unsigned Request; AcceptRequestDataIn *DataIn; long DataOut; { unsigned oldDB = SaveDB(); if (Request == finderSaysSelectionChanged) { InitCursor (); AlertWindow (0x0000,NULL,"40/Request Code = finderSaysSelectionChanged\rDataIn and DataOut are reserved./^OK"); RestoreDB(oldDB); return (0x8000); } RestoreDB(oldDB); return (0x0000); } /* This proc handles the finderSaysMItemSelected request */ pascal int MItemSelectedRequestProc(Request,DataIn,DataOut) unsigned Request; AcceptRequestDataIn *DataIn; finderSaysMItemSelectedOut *DataOut; { unsigned oldDB = SaveDB(); if (Request == finderSaysMItemSelected) { InitCursor (); if(GetCtlValue(GetCtlHandleFromID(FinderXDAWindPtr,0x00000902L)) != 0x0000) /* Check the AbortItFlag control */ { DataOut -> abortItFlag = 0x0001; /* If control checked, tell the Finder not to hadle the selection */ } else { DataOut -> abortItFlag = 0x0000; /* Else tell the Finder to handle the selection */ } finderSaysMItemSelectedProc(DataIn); RestoreDB(oldDB); return (0x8000); } RestoreDB(oldDB); return (0x0000); } /* This proc handles the finderSaysBeforeOpen request */ pascal int BeforeOpenRequestProc(Request,DataIn,DataOut) unsigned Request; AcceptRequestDataIn *DataIn; long DataOut; { GSString255Ptr PathnamePtr; static char Pathname[255]; unsigned oldDB = SaveDB(); if (Request == finderSaysBeforeOpen) { InitCursor (); PathnamePtr = (GSString255Ptr)(DataIn -> finderSaysBeforeOpenInputBuffer.pathname); strncpy(Pathname,PathnamePtr -> text,PathnamePtr -> length); Pathname[PathnamePtr -> length] = 0; sprintf(AlertString, "90/Request Code = finderSaysBeforeOpen\rpCount = $%x\rPathname Pointer = $%lxL\tZoom Rect Pointer = $%lxL\rFiletype = $%x\tAux Type = $%lxL\tModifiers = $%x\rIcon Obj = $%lx\tprintFlag = $%x\rPathname = %s/^OK", DataIn -> finderSaysBeforeOpenInputBuffer.pCount, DataIn -> finderSaysBeforeOpenInputBuffer.pathname, DataIn -> finderSaysBeforeOpenInputBuffer.zoomRect, DataIn -> finderSaysBeforeOpenInputBuffer.filetype, DataIn -> finderSaysBeforeOpenInputBuffer.auxtype, DataIn -> finderSaysBeforeOpenInputBuffer.modifiers, DataIn -> finderSaysBeforeOpenInputBuffer.theIconObj, DataIn -> finderSaysBeforeOpenInputBuffer.printFlag, Pathname); AlertWindow (0x0000,0L,AlertString); RestoreDB(oldDB); return (0x8000); } RestoreDB(oldDB); return (0x0000); } /* This proc handles the finderSaysOpenFailed request */ pascal int OpenFailedRequestProc(Request,DataIn,DataOut) unsigned Request; AcceptRequestDataIn *DataIn; long DataOut; { GSString255Ptr PathnamePtr; static char Pathname[255]; unsigned oldDB = SaveDB(); if (Request == finderSaysOpenFailed) { InitCursor (); PathnamePtr = (GSString255Ptr)(DataIn -> finderSaysOpenFailedInputBuffer.pathname); strncpy(Pathname,PathnamePtr -> text,PathnamePtr -> length); Pathname[PathnamePtr -> length] = 0; sprintf(AlertString, "90/Request Code = finderSaysOpenFailed\rpCount = $%x\rPathname Pointer = $%lxL\tZoom Rect Pointer = $%lxL\rFiletype = $%x\tAux Type = $%lxL\tModifiers = $%x\rIcon Obj = $%lx\tprintFlag = $%x\rPathname = %s/^OK", DataIn -> finderSaysOpenFailedInputBuffer.pCount, DataIn -> finderSaysOpenFailedInputBuffer.pathname, DataIn -> finderSaysOpenFailedInputBuffer.zoomRect, DataIn -> finderSaysOpenFailedInputBuffer.filetype, DataIn -> finderSaysOpenFailedInputBuffer.auxtype, DataIn -> finderSaysOpenFailedInputBuffer.modifiers, DataIn -> finderSaysBeforeOpenInputBuffer.theIconObj, DataIn -> finderSaysBeforeOpenInputBuffer.printFlag, Pathname); AlertWindow (0x0000,0L,AlertString); RestoreDB(oldDB); return (0x8000); } RestoreDB(oldDB); return (0x0000); } /* This proc handles the finderSaysBeforeCopy request */ pascal int BeforeCopyRequestProc(Request,DataIn, DataOut) unsigned Request; AcceptRequestDataIn *DataIn; finderSaysBeforeCopyOut *DataOut; { GSString255Ptr sourcePathnamePtr; GSString255Ptr destinationPathnamePtr; char *subArray[2]; int sourcePathnameLength; int destinationPathnameLength; char *pSource; char *pDestination; word ButtonSelected; unsigned oldDB = SaveDB(); if(Request == finderSaysBeforeCopy) { InitCursor (); sourcePathnamePtr = (GSString255Ptr)(DataIn -> finderSaysBeforeCopyInputBuffer.sourcePathname); subArray[0] = (char *)sourcePathnamePtr + 1; sourcePathnameLength = sourcePathnamePtr -> length; pSource = (char *)sourcePathnamePtr; pSource[1] = pSource[0]; destinationPathnamePtr = (GSString255Ptr)(DataIn -> finderSaysBeforeCopyInputBuffer.destinationPathname); subArray[1] = (char *)destinationPathnamePtr + 1; destinationPathnameLength = destinationPathnamePtr -> length; pDestination = (char *)destinationPathnamePtr; pDestination[1] = pDestination[0]; sprintf(AlertString,"90/Request Code = finderSaysBeforeCopy\rpCount = $%x\rSource Pathname Ptr = $%lxL\rDestination Pathname Ptr = $%lxL\rSource Pathname = *0\rDestination Pathname = *1/^Allow Copy/Cancel", DataIn -> finderSaysBeforeCopyInputBuffer.pCount, DataIn -> finderSaysBeforeCopyInputBuffer.sourcePathname, DataIn -> finderSaysBeforeCopyInputBuffer.destinationPathname); ButtonSelected = AlertWindow (0x0001,subArray,AlertString); sourcePathnamePtr -> length = sourcePathnameLength; destinationPathnamePtr -> length = destinationPathnameLength; if (ButtonSelected == 0x0001) /* Check the AlertWindow button selected to see if the copy should be allowed, */ { /* if = 1, don't allow it */ DataOut -> abortFlag = 0x0001; } RestoreDB(oldDB); return 0x8000; } RestoreDB(oldDB); return 0x0000; } /* This proc handles the finderSaysIdle request */ pascal int IdleRequestProc(Request,DataIn,DataOut) unsigned Request; long DataIn; long DataOut; { WindowPtr OldPort; unsigned oldDB = SaveDB(); if (Request == finderSaysIdle) { OldPort = GetPort(); SetPort(FinderXDAWindPtr); SetRect(&IdleRect,390,52,410,62); if (finderSaysIdleFlag == 0) { PaintRect(&IdleRect); ++finderSaysIdleFlag; } else { EraseRect(&IdleRect); --finderSaysIdleFlag; } SetPort(OldPort); RestoreDB(oldDB); return 0x8000; } RestoreDB(oldDB); return 0x0000; } DisposeIdleProc() { WindowPtr OldPort; AcceptRequests ("\pAppleComputer~FinderXDAIdle~",MMStartUp(),0L); OldPort = GetPort(); SetPort(FinderXDAWindPtr); EraseRect(&IdleRect); SetPort(OldPort); } /* This proc handles the finderSaysExtrasChosen request */ pascal int ExtrasChosenRequestProc(Request,DataIn,DataOut) unsigned Request; AcceptRequestDataIn *DataIn; long DataOut; { unsigned oldDB = SaveDB(); if (Request == finderSaysExtrasChosen) { InitCursor (); finderSaysExtrasChosenProc(DataIn); RestoreDB(oldDB); return (0x8000); } RestoreDB(oldDB); return (0x0000); } /* This proc handles the finderSaysBeforeRename request */ pascal int BeforeRenameRequestProc(Request,DataIn,DataOut) unsigned Request; AcceptRequestDataIn *DataIn; finderSaysBeforeRenameOut *DataOut; { GSString255Ptr oldPathnamePtr; GSString255Ptr newPathnamePtr; char *subArray[2]; int oldPathnameLength; int newPathnameLength; char *pOld; char *pNew; word ButtonSelected; unsigned oldDB = SaveDB(); if (Request == finderSaysBeforeRename) { InitCursor (); oldPathnamePtr = (GSString255Ptr)(DataIn -> finderSaysBeforeRenameInputBuffer.oldPathname); subArray[0] = (char *)oldPathnamePtr + 1; oldPathnameLength = oldPathnamePtr -> length; pOld = (char *)oldPathnamePtr; pOld[1] = pOld[0]; newPathnamePtr = (GSString255Ptr)(DataIn -> finderSaysBeforeRenameInputBuffer.newPathname); subArray[1] = (char *)newPathnamePtr + 1; newPathnameLength = newPathnamePtr -> length; pNew = (char *)newPathnamePtr; pNew[1] = pNew[0]; sprintf(AlertString,"90/Request Code = finderSaysBeforeRename\rpCount = $%x\rOld Pathname Pointer = $%lxL\tNew Pathname Pointer = $%lxL\rFile Type = $%x\tFile Aux Type = $%lxL\rOld Pathname = *0\rNew Pathname = *1/^Allow Rename/Cancel", DataIn -> finderSaysBeforeRenameInputBuffer.pCount, DataIn -> finderSaysBeforeRenameInputBuffer.oldPathname, DataIn -> finderSaysBeforeRenameInputBuffer.newPathname, DataIn -> finderSaysBeforeRenameInputBuffer.filetype, DataIn -> finderSaysBeforeRenameInputBuffer.auxtype); ButtonSelected = AlertWindow (0x0001,subArray,AlertString); oldPathnamePtr -> length = oldPathnameLength; newPathnamePtr -> length = newPathnameLength; if (ButtonSelected == 0x0001) { DataOut -> abortFlag = 0x0001; } RestoreDB(oldDB); return 0x8000; } RestoreDB(oldDB); return 0x0000; } /* This proc handles the finderSaysKeyHit request */ pascal int KeyHitRequestProc(Request,DataIn,DataOut) unsigned Request; AcceptRequestDataIn *DataIn; long DataOut; { unsigned oldDB = SaveDB(); if (Request == finderSaysKeyHit) { InitCursor (); sprintf(AlertString,"40/Request Code = finderSaysKeyHit\rpCount = $%x\rTaskMaster Message = $%x\rModifiers = $%x/^OK", DataIn -> finderSaysKeyHitInputBuffer.pCount, DataIn -> finderSaysKeyHitInputBuffer.message, DataIn -> finderSaysKeyHitInputBuffer.modifiers); AlertWindow (0x0000,NULL,AlertString); RestoreDB(oldDB); return 0x8000; } RestoreDB(oldDB); return 0x0000; } /* A function to remove all the AcceptRequest procs */ RemoveRequestProcs () { AcceptRequests ("\pAppleComputer~FinderXDAHello~",MMStartUp(),0L); AcceptRequests ("\pAppleComputer~FinderXDAGoodbye~",MMStartUp(),0L); AcceptRequests ("\pAppleComputer~FinderXDASelectionChanged~",MMStartUp(),0L); AcceptRequests ("\pAppleComputer~FinderXDAMItemSelected~",MMStartUp(),0L); AcceptRequests ("\pAppleComputer~FinderXDABeforeOpen~",MMStartUp(),0L); AcceptRequests ("\pAppleComputer~FinderXDAOpenFailed~",MMStartUp(),0L); AcceptRequests ("\pAppleComputer~FinderXDABeforeCopy~",MMStartUp(),0L); DisposeIdleProc(); AcceptRequests ("\pAppleComputer~FinderXDAExtrasChosen~",MMStartUp(),0L); AcceptRequests ("\pAppleComputer~FinderXDABeforeRename~",MMStartUp(),0L); AcceptRequests ("\pAppleComputer~FinderXDAKeyHit~",MMStartUp(),0L); AcceptRequests ("\pAppleComputer~FinderXDA~",MMStartUp(),0L); } /************************************************************************************************/ /* tellFinder Request Code Handling Procedures */ tellFinderGetDebugInfoProc () { MytellFinderGetDebugInfoOut MytellFinderGetDebugInfoOutput; CtlRecHndl DebugInfoCtlHandle; word ButtonSelected; if(DebugInfoWindPtr == 0) { SendRequest (tellFinderGetDebugInfo,0x8001,finderTarget,0L,(long)&MytellFinderGetDebugInfoOutput); sprintf(AlertString,"Request Code = tellFinderGetDebugInfo\rrecvCount = $%x\rResult Code = $%x\rpCount = $%x\rDirect Page = $%x\rdeskIC = $%lxL\rnameChainH = $%lxL\rfiletypeBlock = $%lxL\rdeviceBlock = $%lxL\rmasterChainH = $%lxL\rfinderPathsH = $%lxL\rfinderPathsCount = $%x\rchainTable = $%lx\riconOffsetArray = $%lx\riconHandleArray = $%lx\riconArrayUsed = $%x\riconArraySize = $%x", MytellFinderGetDebugInfoOutput.recvCount, MytellFinderGetDebugInfoOutput.finderResult, MytellFinderGetDebugInfoOutput.pCount, MytellFinderGetDebugInfoOutput.directPage, MytellFinderGetDebugInfoOutput.deskIcon, MytellFinderGetDebugInfoOutput.nameChainH, MytellFinderGetDebugInfoOutput.filetypeBlock, MytellFinderGetDebugInfoOutput.deviceBlock, MytellFinderGetDebugInfoOutput.masterChainH, MytellFinderGetDebugInfoOutput.rFPListHandle, MytellFinderGetDebugInfoOutput.rFPCount, MytellFinderGetDebugInfoOutput.chainTable, MytellFinderGetDebugInfoOutput.iconOffsetArray, MytellFinderGetDebugInfoOutput.iconHandleArray, MytellFinderGetDebugInfoOutput.iconArrayUsed, MytellFinderGetDebugInfoOutput.iconArraySize); DebugInfoWindPtr = NewWindow (&DebugInfoWindParams); if(_toolErr) CheckError(_toolErr,0x0001); else { SetUpDebugInfoNDASysWindRec(); SetSysWindow(DebugInfoWindPtr); DebugInfoAuxWindRecPtr = (AuxWindInfoPtr)(GetAuxWindInfo(DebugInfoWindPtr)); DebugInfoAuxWindRecPtr -> NDASysWindPtr = (Ptr)&DebugInfoNDASysWindRec; DebugInfoCtlHandle = NewControl2(DebugInfoWindPtr,0,&MyWindCtl); if(_toolErr) CheckError(_toolErr,0x0001); TEInsert (0x0001,AlertString,0L,0,0L,DebugInfoCtlHandle); (**(TERecordHndl)GetCtlHandleFromID(NIL,0x00001000L)).textFlags |= 0x04000000; } } else { ButtonSelected = AlertWindow (0x0000,0L,"42/A tellFinderGetGetDebugInfo window is already open. Do you want to close it?/^Close Window/Cancel"); if (ButtonSelected == 0) { CloseIfOpen(&DebugInfoWindPtr); } } } tellFinderAreYouThereProc () { tellFinderAreYouThereOut tellFinderAreYouThereOutput; SendRequest (askFinderAreYouThere,0x8001,finderTarget,0L,&tellFinderAreYouThereOutput); CheckError(tellFinderAreYouThereOutput.finderResult,0x0000); sprintf(AlertString,"40/Request Code = tellFinderAreYouThere\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK", tellFinderAreYouThereOutput.recvCount, tellFinderAreYouThereOutput.finderResult, ErrorString); AlertWindow (0x0000,0L,AlertString); } tellFinderOpenWindowProc () { tellFinderOpenWindowOut tellFinderOpenWindowOutput; GSString255 Pathname; long PathnameLength; PathnameLength = TEGetText (0x0002,(long)&Pathname,110L,0x0000,0L,0L); if(PathnameLength == NIL) { AlertWindow (0x0000,0L,"42/You passed an empty pathname. Please enter a pathname and try again./^Continue"); } else { if(_toolErr) CheckError(_toolErr,0x0001); else { SendRequest (tellFinderOpenWindow,0x8001,finderTarget,&Pathname,(long)&tellFinderOpenWindowOutput); CheckError(tellFinderOpenWindowOutput.finderResult,0x0000); sprintf(AlertString,"40/Request Code = tellFinderOpenWindow\rrecvCount = $%x\rResult Code = $%x\rWindow Pointer = $%lxL\rError - %s/^OK", tellFinderOpenWindowOutput.recvCount, tellFinderOpenWindowOutput.finderResult, tellFinderOpenWindowOutput.window, ErrorString); AlertWindow (0x0000,0L,AlertString); } } } tellFinderCloseWindowProc () { tellFinderCloseWindowOut tellFinderCloseWindowOutput; GSString255 Pathname; long PathnameLength; PathnameLength = TEGetText (0x0002,(long)&Pathname,110L,0x0000,0L,0L); if(PathnameLength == NIL) { AlertWindow (0x0000,0L,"42/You passed an empty pathname. Please enter a pathname and try again./^Continue"); } else { if(_toolErr) CheckError(_toolErr,0x0001); else { SendRequest (tellFinderCloseWindow,0x8001,finderTarget,&Pathname,(long)&tellFinderCloseWindowOutput); CheckError(tellFinderCloseWindowOutput.finderResult,0x0000); sprintf(AlertString,"40/Request Code = tellFinderCloseWindow\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK", tellFinderCloseWindowOutput.recvCount, tellFinderCloseWindowOutput.finderResult, ErrorString); AlertWindow (0x0000,0L,AlertString); } } } /* This function is called by the tellFinderGetSelectedIconsProc and the tellFinderGetWindowIconsProc for */ /* outputing extended icon data to the result window and advancing the pointeraddress */ OutputAWord(MyString,PointerAddress,PathnameCtlHandle) char MyString[]; Ptr *PointerAddress; CtlRecHndl PathnameCtlHandle; { char wordString[4]; TEInsert (0x0001,MyString,0L,0,0L,PathnameCtlHandle); if(_toolErr) CheckError(_toolErr,0x0001); Int2Hex(**(word **)PointerAddress,wordString,4); TEInsert (0x0005,wordString,4L,0,0L,PathnameCtlHandle); if(_toolErr) CheckError(_toolErr,0x0001); TEInsert (0x0001,"\r",0L,0,0L,PathnameCtlHandle); if(_toolErr) CheckError(_toolErr,0x0001); *PointerAddress += 2; } tellFinderGetSelectedIconsProc () { CtlRecHndl PathnameCtlHandle; Ptr PointerAddress; Ptr StringAddress; int i; word ButtonSelected; word yIcon; word xIcon; word yIconText; word iconHeight; word iconWidth; char yIconString[4]; char xIconString[4]; char yIconTextString[4]; char iconHeightString[4]; char iconWidthString[4]; if(GetSelectedIconsWindPtr == 0) { if (tellFinderGetSelectedIconsOutput.stringListHandle != NIL) { DisposeHandle((long)tellFinderGetSelectedIconsOutput.stringListHandle &~0x80000000L); if(_toolErr) CheckError(_toolErr,0x0001); tellFinderGetSelectedIconsOutput.stringListHandle = NIL; } if(GetCtlValue(GetCtlHandleFromID(GetSelectedIconsWindPtr,0x00000903L)) == 0) { SendRequest (tellFinderGetSelectedIcons,0x8001,finderTarget,0L,(long)&tellFinderGetSelectedIconsOutput); sprintf(AlertString,"40/Request Code = tellFinderGetSelectedIcons\rrecvCount = $%x\tResult Code = $%x\rIcon Window Pointer = $%lxL\rStringList Handle = $%lxL\rNumber of Pathnames to follow = $%x/^OK", tellFinderGetSelectedIconsOutput.recvCount, tellFinderGetSelectedIconsOutput.finderResult, tellFinderGetSelectedIconsOutput.iconWindowPtr, tellFinderGetSelectedIconsOutput.stringListHandle, **(word **)tellFinderGetSelectedIconsOutput.stringListHandle); AlertWindow (0x0000,0L,AlertString); if ((**(word **)tellFinderGetSelectedIconsOutput.stringListHandle) != 0) { GetSelectedIconsWindPtr = NewWindow (&GetSelectedIconsWindParams); if(_toolErr) CheckError(_toolErr,0x0001); else { SetUpGetSelectedIconsNDASysWindRec(); SetSysWindow(GetSelectedIconsWindPtr); GetSelectedIconsAuxWindRecPtr = (AuxWindInfoPtr)(GetAuxWindInfo(GetSelectedIconsWindPtr)); GetSelectedIconsAuxWindRecPtr -> NDASysWindPtr = (Ptr)&GetSelectedIconsNDASysWindRec; PathnameCtlHandle = NewControl2(GetSelectedIconsWindPtr,0,&MyWindCtl); if(_toolErr) CheckError(_toolErr,0x0001); else { PointerAddress = (*tellFinderGetSelectedIconsOutput.stringListHandle)+2; for (i = 0; i < **(word **)tellFinderGetSelectedIconsOutput.stringListHandle; i++) { TEInsert (0x0002,PointerAddress,0L,0,0L,PathnameCtlHandle); if(_toolErr) CheckError(_toolErr,0x0001); TEInsert (0x0001,"\r\r",0L,0,0L,PathnameCtlHandle); if(_toolErr) CheckError(_toolErr,0x0001); PointerAddress += *(word *)PointerAddress + 2; } (**(TERecordHndl)GetCtlHandleFromID(NIL,0x00001000L)).textFlags |= 0x04000000; } } } } else { SendRequest (tellFinderGetSelectedIcons,0x8001,finderTarget,0x80000000L,(long)&tellFinderGetSelectedIconsOutput); sprintf(AlertString,"40/Request Code = tellFinderGetSelectedIcons\rrecvCount = $%x\tResult Code = $%x\rIcon Window Pointer = $%lxL\rStringList Handle = $%lxL\rNumber of Pathnames to follow = $%x/^OK", tellFinderGetSelectedIconsOutput.recvCount, tellFinderGetSelectedIconsOutput.finderResult, tellFinderGetSelectedIconsOutput.iconWindowPtr, tellFinderGetSelectedIconsOutput.stringListHandle, **(word **)tellFinderGetSelectedIconsOutput.stringListHandle); AlertWindow (0x0000,0L,AlertString); if ((**(word **)tellFinderGetSelectedIconsOutput.stringListHandle) != 0) { GetSelectedIconsWindPtr = NewWindow (&GetSelectedIconsWindParams); if(_toolErr) CheckError(_toolErr,0x0001); else { SetUpGetSelectedIconsNDASysWindRec(); SetSysWindow(GetSelectedIconsWindPtr); GetSelectedIconsAuxWindRecPtr = (AuxWindInfoPtr)(GetAuxWindInfo(GetSelectedIconsWindPtr)); GetSelectedIconsAuxWindRecPtr -> NDASysWindPtr = (Ptr)&GetSelectedIconsNDASysWindRec; PathnameCtlHandle = NewControl2(GetSelectedIconsWindPtr,0,&MyWindCtl); if(_toolErr) CheckError(_toolErr,0x0001); else { HLock((long)tellFinderGetSelectedIconsOutput.stringListHandle &~0x80000000); PointerAddress = (*tellFinderGetSelectedIconsOutput.stringListHandle)+2; for (i = 0; i < **(word **)tellFinderGetSelectedIconsOutput.stringListHandle; i++) { StringAddress = *(word *)PointerAddress + PointerAddress; TEInsert (0x0001,"\r",0L,0,0L,PathnameCtlHandle); TEInsert (0x0002,StringAddress,0L,0,0L,PathnameCtlHandle); TEInsert (0x0001,"\r",0L,0,0L,PathnameCtlHandle); PointerAddress += 2; OutputAWord("\ty coordinate (bottom) of Icon, Icon view - $",&PointerAddress,PathnameCtlHandle); OutputAWord("\tx coordinate (middle) of Icon, Icon view - $",&PointerAddress,PathnameCtlHandle); OutputAWord("\ty coordinate of Icon, list view - $",&PointerAddress,PathnameCtlHandle); OutputAWord("\tHeight of Icon for current view - $",&PointerAddress,PathnameCtlHandle); OutputAWord("\tWidth of Icon for current view - $",&PointerAddress,PathnameCtlHandle); PointerAddress = StringAddress + *(word *)StringAddress + 2; } HUnlock((long)tellFinderGetSelectedIconsOutput.stringListHandle &~0x80000000); (**(TERecordHndl)GetCtlHandleFromID(NIL,0x00001000L)).textFlags |= 0x04000000; } } } } } else { ButtonSelected = AlertWindow (0x0000,0L,"42/A tellFinderGetSelectedIcons window is already open. Do you want to close it?/^Close Window/Cancel"); if (ButtonSelected == 0) { CloseIfOpen(&GetSelectedIconsWindPtr); } } } tellFinderSetSelectedIconsProc () { tellFinderSetSelectedIconsOut tellFinderSetSelectedIconsOutput; if(GetCtlValue(GetCtlHandleFromID(FinderXDAWindPtr,0x0000805AL)) == 0x0001) { tellFinderGetSelectedIconsOutput.stringListHandle = (handle)(((long)tellFinderGetSelectedIconsOutput.stringListHandle) | 0x80000000L); } else { tellFinderGetSelectedIconsOutput.stringListHandle = (handle)(((long)tellFinderGetSelectedIconsOutput.stringListHandle) & ~0x80000000L); } SendRequest (tellFinderSetSelectedIcons,0x8001,finderTarget,tellFinderGetSelectedIconsOutput.stringListHandle,(long)&tellFinderSetSelectedIconsOutput); CheckError(tellFinderSetSelectedIconsOutput.finderResult,0x0000); sprintf(AlertString,"40/Request Code = tellFinderSetSelectedIcons\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK", tellFinderSetSelectedIconsOutput.recvCount, tellFinderSetSelectedIconsOutput.finderResult, ErrorString); AlertWindow (0x0000,0L,AlertString); } tellFinderLaunchThis_Ap_Proc () { tellFinderLaunchThisIn tellFinderLaunchThisInput; tellFinderLaunchThisOut tellFinderLaunchThisOutput; GSString255 Class1Pathname; TEGetText (0x0002,(long)&Class1Pathname,110L,0x0000,0L,0L); if(_toolErr) CheckError(_toolErr,0x0001); else { tellFinderLaunchThisInput.launchprint = 0x0000; tellFinderLaunchThisInput.pathname = (ptr)&Class1Pathname; SendRequest (tellFinderLaunchThis,0x8001,finderTarget,&tellFinderLaunchThisInput,(long)&tellFinderLaunchThisOutput); CheckError(tellFinderLaunchThisOutput.finderResult,0x0000); sprintf(AlertString,"40/Request Code = tellFinderLaunchThis_Ap\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK", tellFinderLaunchThisOutput.recvCount, tellFinderLaunchThisOutput.finderResult, ErrorString); AlertWindow (0x0000,0L,AlertString); CloseFromNDA(); } } tellFinderShutDown_PowerOff_Proc () { tellFinderShutDownOut tellFinderShutDownOutput; SendRequest (tellFinderShutDown,0x8001,finderTarget,0x00000000L,(long)&tellFinderShutDownOutput); CheckError(tellFinderShutDownOutput.finderResult,0x0000); sprintf(AlertString,"80/Request Code = tellFinderShutDown_PowerOff\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK", tellFinderShutDownOutput.recvCount, tellFinderShutDownOutput.finderResult, ErrorString); AlertWindow (0x0000,0L,AlertString); CloseFromNDA(); } tellFinderShutDown_Restart_Proc () { tellFinderShutDownOut tellFinderShutDownOutput; SendRequest (tellFinderShutDown,0x8001,finderTarget,0x00000001L,(long)&tellFinderShutDownOutput); CheckError(tellFinderShutDownOutput.finderResult,0x0000); sprintf(AlertString,"80/Request Code = tellFinderShutDown_Restart\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK", tellFinderShutDownOutput.recvCount, tellFinderShutDownOutput.finderResult, ErrorString); AlertWindow (0x0000,0L,AlertString); CloseFromNDA(); } tellFinderShutDown_QuitFinder_Proc () { tellFinderShutDownOut tellFinderShutDownOutput; SendRequest (tellFinderShutDown,0x8001,finderTarget,0x00000002L,(long)&tellFinderShutDownOutput); CheckError(tellFinderShutDownOutput.finderResult,0x0000); sprintf(AlertString,"80/Request Code = tellFinderShutDown_QuitFinder\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK", tellFinderShutDownOutput.recvCount, tellFinderShutDownOutput.finderResult, ErrorString); AlertWindow (0x0000,0L,AlertString); CloseFromNDA(); } tellFinderMItemSelectedProc(MItemSelectedID) word MItemSelectedID; { GrafPortPtr VisWindPtr; tellFinderMItemSelectedIn tellFinderMItemSelectedInput; tellFinderMItemSelectedOut tellFinderMItemSelectedOutput; tellFinderOpenWindowOut tellFinderOpenWindowOutput; tellFinderGetWindowInfoOut tellFinderGetWindowInfoOutput; tellFinderMItemSelectedInput.menuItemID = MItemSelectedID; tellFinderMItemSelectedInput.modifiers = 0; if(GetCtlValue(GetCtlHandleFromID(FinderXDAWindPtr,0x00000901L)) == 0x0001) { tellFinderMItemSelectedInput.flags = 0x8000; } VisWindPtr = findNextVisWindow(); /* We have to bring the Finder window to the front so the menuitems can operate on it */ if (VisWindPtr != NIL) { SendRequest (tellFinderGetWindowInfo,0x8001,finderTarget,VisWindPtr,(long)&tellFinderGetWindowInfoOutput); if(((GSString255Ptr)tellFinderGetWindowInfoOutput.windPath) -> length) { SendRequest (tellFinderOpenWindow,0x8001,finderTarget,tellFinderGetWindowInfoOutput.windPath,(long)&tellFinderOpenWindowOutput); } } SendRequest (tellFinderMItemSelected,0x8001,finderTarget,&tellFinderMItemSelectedInput,(long)&tellFinderMItemSelectedOutput); CheckError(tellFinderMItemSelectedOutput.finderResult,0x0000); sprintf(AlertString,"40/Finder Result = $%x\rError - %s/^OK", tellFinderMItemSelectedOutput.finderResult, ErrorString); AlertWindow (0x0000,NULL,AlertString); } tellFinderMatchFileToIconProc () { AlertWindow (0x0000,NULL,"40/tellFinderMatchFileToIcon is not implemented by this tool yet./^OK"); } tellFinderAddBundleProc () { AlertWindow (0x0000,NULL,"40/tellFinderAddBundle is not implemented by this tool yet./^OK"); } tellFinderAboutChangeProc () { tellFinderAboutChangeOut tellFinderAboutChangeOutput; GSString255 Pathname; TEGetText (0x0002,(long)&Pathname,110L,0x0000,0L,GetCtlHandleFromID(NIL,401L)); if(_toolErr) CheckError(_toolErr,0x0001); else { SendRequest (tellFinderAboutChange,0x8001,finderTarget,(long)&Pathname,(long)&tellFinderAboutChangeOutput); CheckError(tellFinderAboutChangeOutput.finderResult,0); sprintf(AlertString,"40/Request Code = tellFinderAboutChange\rFinder Result = $%x\rError - %s/^OK", tellFinderAboutChangeOutput.finderResult, ErrorString); AlertWindow (0x0000,NULL,AlertString); } } tellFinderCheckDatabaseProc () { AlertWindow (0x0000,NULL,"40/tellFinderCheckDatabase is not implemented by this tool yet./^OK"); } tellFinderColorSelectionProc() { tellFinderColorSelectionOut tellFinderColorSelectionOutput; char ColorValueString[8]; long iconColorValue; TEGetText (0x0001,ColorValueString,10L,0x0000,0L,GetCtlHandleFromID(NIL,501L)); if(_toolErr) CheckError(_toolErr,0x0001); else { if (strlen(ColorValueString) < 8) { AlertWindow (0x0000,NULL,"30/Too few characters in string./^OK"); } else { iconColorValue = Hex2Long(ColorValueString,8); if(_toolErr) CheckError(_toolErr,0x0001); else { SendRequest (tellFinderColorSelection,0x8001,finderTarget,iconColorValue,(long)&tellFinderColorSelectionOutput); if(tellFinderColorSelectionOutput.finderResult != 0x0000) { CheckError(tellFinderColorSelectionOutput.finderResult,0x0000); sprintf(AlertString,"30/Finder Result = $%x\r%s\rError - %s/^OK", tellFinderColorSelectionOutput.finderResult, ErrorString); AlertWindow (0x0000,NULL,AlertString); } } } } } tellFinderAddToExtrasProc () { tellFinderAddToExtrasOut tellFinderAddToExtrasOutput; static char *menuItemTitle[MAXNUMMENUITEMS] = { "\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx", "\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx", "\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx", "\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx" }; if (menuItemIndex < MAXNUMMENUITEMS) { if (menuItemIndex == 0) { tellFinderAddToExtrasMenuItem.version = 0x8000; } else { tellFinderAddToExtrasMenuItem.version = 0x0000; } SendRequest (tellFinderAddToExtras,0x8001,finderTarget,(long)&tellFinderAddToExtrasMenuItem,(long)&tellFinderAddToExtrasOutput); menuItemID[menuItemIndex] = tellFinderAddToExtrasOutput.menuItemID; Int2Hex(menuItemID[menuItemIndex],menuItemTitle[menuItemIndex] + 15,4); if(_toolErr) CheckError(_toolErr,0x0001); else { SetMItemName2(0x0000,(long)menuItemTitle[menuItemIndex],menuItemID[menuItemIndex]); CheckError(tellFinderAddToExtrasOutput.finderResult,0x0000); sprintf(AlertString,"40/Request Code = tellFinderAddToExtras\rrecvCount = $%x\rResult Code = $%x\rMenuItem ID Added = $%x\tMenu ID = $%x\rError - %s/^OK", tellFinderAddToExtrasOutput.recvCount, tellFinderAddToExtrasOutput.finderResult, menuItemID[menuItemIndex], tellFinderAddToExtrasOutput.menuID, ErrorString); AlertWindow (0x0000,0L,AlertString); return ++menuItemIndex; } } else { sprintf(AlertString,"42/You have %d menu items allocated. This is the maximum number that this test tool allows./^OK", MAXNUMMENUITEMS); AlertWindow (0x0000,0L,AlertString); } } tellFinderIdleHowLongProc () { tellFinderIdleHowLongOut tellFinderIdleHowLongOutput; SendRequest (askFinderIdleHowLong,0x8001,finderTarget,0L,(long)&tellFinderIdleHowLongOutput); CheckError(tellFinderIdleHowLongOutput.finderResult,0x0000); sprintf(AlertString,"40/Request Code = tellFinderIdleHowLong\rrecvCount = $%x\rResult Code = $%x\rTick Count = $%lxL\rError - %s/^OK", tellFinderIdleHowLongOutput.recvCount, tellFinderIdleHowLongOutput.finderResult, tellFinderIdleHowLongOutput.tickCount, ErrorString); AlertWindow (0x0000,0L,AlertString); } tellFinderGetWindowIconsProc () { tellFinderGetWindowIconsOut tellFinderGetWindowIconsOutput; GrafPortPtr VisWindPtr; CtlRecHndl PathnameCtlHandle; Ptr PointerAddress; Ptr StringAddress; int i; char ReturnString[16]; word ButtonSelected; word NumIcons; if(GetWindowIconsWindPtr == 0) { VisWindPtr = findNextVisWindow(); if(VisWindPtr != NIL) { if(GetCtlValue(GetCtlHandleFromID(GetSelectedIconsWindPtr,0x00000903L)) == 0) { SendRequest (tellFinderGetWindowIcons,0x8001,finderTarget,VisWindPtr,(long)&tellFinderGetWindowIconsOutput); sprintf(AlertString,"40/Request Code = tellFinderGetWindowIcons\rrecvCount = $%x\rResult Code = $%x\rStringList Handle = $%lxL\rNumber of Pathnames to follow = $%x/^OK", tellFinderGetWindowIconsOutput.recvCount, tellFinderGetWindowIconsOutput.finderResult, tellFinderGetWindowIconsOutput.stringListHandle, **(word **)tellFinderGetWindowIconsOutput.stringListHandle); AlertWindow (0x0000,0L,AlertString); if ((**(word **)tellFinderGetWindowIconsOutput.stringListHandle) != 0) { GetWindowIconsWindPtr = NewWindow (&GetWindowIconsWindParams); if(_toolErr) CheckError(_toolErr,0x0001); else { SetUpGetWindowIconsNDASysWindRec(); SetSysWindow(GetWindowIconsWindPtr); GetWindowIconsAuxWindRecPtr = (AuxWindInfoPtr)(GetAuxWindInfo(GetWindowIconsWindPtr)); GetWindowIconsAuxWindRecPtr -> NDASysWindPtr = (Ptr)&GetWindowIconsNDASysWindRec; PathnameCtlHandle = NewControl2(GetWindowIconsWindPtr,0,&MyWindCtl); if(_toolErr) CheckError(_toolErr,0x0001); else { HLock(tellFinderGetWindowIconsOutput.stringListHandle); PointerAddress = (*tellFinderGetWindowIconsOutput.stringListHandle)+2; for (i = 0; i < **(word **)tellFinderGetWindowIconsOutput.stringListHandle; i++) { TEInsert (0x0002,PointerAddress,0L,0,0L,PathnameCtlHandle); TEInsert (0x0001,"\r\r",0L,0,0L,PathnameCtlHandle); PointerAddress += *(word *)PointerAddress + 2; } (**(TERecordHndl)GetCtlHandleFromID(NIL,0x00001000L)).textFlags |= 0x04000000; DisposeHandle(tellFinderGetWindowIconsOutput.stringListHandle); if(_toolErr) CheckError(_toolErr,0x0001); tellFinderGetSelectedIconsOutput.stringListHandle = NIL; } } } } else { SendRequest (tellFinderGetWindowIcons,0x8001,finderTarget,(long)VisWindPtr|0x80000000,(long)&tellFinderGetWindowIconsOutput); NumIcons = **(word **)tellFinderGetWindowIconsOutput.stringListHandle; sprintf(AlertString,"40/Request Code = tellFinderGetWindowIcons\rrecvCount = $%x\rResult Code = $%x\rStringList Handle = $%lxL\rNumber of Pathnames to follow = $%x/^OK", tellFinderGetWindowIconsOutput.recvCount, tellFinderGetWindowIconsOutput.finderResult, tellFinderGetWindowIconsOutput.stringListHandle, NumIcons); AlertWindow (0x0000,0L,AlertString); if (NumIcons) { GetWindowIconsWindPtr = NewWindow (&GetWindowIconsWindParams); if(_toolErr) CheckError(_toolErr,0x0001); else { SetUpGetWindowIconsNDASysWindRec(); SetSysWindow(GetWindowIconsWindPtr); GetWindowIconsAuxWindRecPtr = (AuxWindInfoPtr)(GetAuxWindInfo(GetWindowIconsWindPtr)); GetWindowIconsAuxWindRecPtr -> NDASysWindPtr = (Ptr)&GetWindowIconsNDASysWindRec; PathnameCtlHandle = NewControl2(GetWindowIconsWindPtr,0,&MyWindCtl); if(_toolErr) CheckError(_toolErr,0x0001); else { HLock((long)tellFinderGetWindowIconsOutput.stringListHandle &~0x80000000); PointerAddress = (*tellFinderGetWindowIconsOutput.stringListHandle)+2; for (i = 0; i < **(word **)tellFinderGetWindowIconsOutput.stringListHandle; i++) { StringAddress = *(word *)PointerAddress + PointerAddress; TEInsert (0x0001,"\r",0L,0,0L,PathnameCtlHandle); TEInsert (0x0002,StringAddress,0L,0,0L,PathnameCtlHandle); TEInsert (0x0001,"\r",0L,0,0L,PathnameCtlHandle); PointerAddress += 2; OutputAWord("\ty coordinate (bottom) of Icon, Icon view - $",&PointerAddress,PathnameCtlHandle); OutputAWord("\tx coordinate (middle) of Icon, Icon view - $",&PointerAddress,PathnameCtlHandle); OutputAWord("\ty coordinate of Icon, list view - $",&PointerAddress,PathnameCtlHandle); OutputAWord("\tHeight of Icon for current view - $",&PointerAddress,PathnameCtlHandle); OutputAWord("\tWidth of Icon for current view - $",&PointerAddress,PathnameCtlHandle); PointerAddress = StringAddress + *(word *)StringAddress + 2; } HUnlock((long)tellFinderGetWindowIconsOutput.stringListHandle &~0x80000000); (**(TERecordHndl)GetCtlHandleFromID(NIL,0x00001000L)).textFlags |= 0x04000000; DisposeHandle(tellFinderGetWindowIconsOutput.stringListHandle); if(_toolErr) CheckError(_toolErr,0x0001); tellFinderGetSelectedIconsOutput.stringListHandle = NIL; } } } } } else { AlertWindow (0x0000,0L,"33/No open window./^OK"); } } else { ButtonSelected = AlertWindow (0x0000,0L,"42/A tellFinderGetWindowIcons window is already open. Do you want to close it?/^Close Window/Cancel"); if (ButtonSelected == 0) { CloseIfOpen(&GetWindowIconsWindPtr); } } } tellFinderGetWindowInfoProc () { tellFinderGetWindowInfoOut tellFinderGetWindowInfoOutput; GrafPortPtr VisWindPtr; GSString255 *windPathPtr; char WindTitle[128]; char WindPath[255]; unsigned EmptyString = 0; VisWindPtr = findNextVisWindow(); if(VisWindPtr != NIL) { SendRequest (tellFinderGetWindowInfo,0x8001,finderTarget,findNextVisWindow(),(long)&tellFinderGetWindowInfoOutput); strncpy (WindTitle,tellFinderGetWindowInfoOutput.windTitle,tellFinderGetWindowInfoOutput.windTitle[0] + 1); p2cstr (WindTitle); if (tellFinderGetWindowInfoOutput.windowType & 0x0012) /* InfoWindID + dirWindID */ { windPathPtr = (GSString255Ptr)(tellFinderGetWindowInfoOutput.windPath); } else { windPathPtr = (GSString255Ptr)&EmptyString; } strncpy (WindPath,windPathPtr -> text,windPathPtr -> length); WindPath[windPathPtr -> length] = 0; sprintf(AlertString,"90/Request Code = tellFinderGetWindowInfo\trecvCount = $%x\rResult Code = $%x\tWindow Type = $%x\rWindow View = $%x\tWindow FST = $%x\rWindow Title = %s\rWindow Path = %s/^OK", tellFinderGetWindowInfoOutput.recvCount, tellFinderGetWindowInfoOutput.finderResult, tellFinderGetWindowInfoOutput.windowType, tellFinderGetWindowInfoOutput.windView, tellFinderGetWindowInfoOutput.windFST, WindTitle, WindPath); AlertWindow (0x0000,0L,AlertString); } else { SendRequest (tellFinderGetWindowInfo,0x8001,finderTarget,findNextVisWindow(),(long)&tellFinderGetWindowInfoOutput); CheckError(tellFinderGetWindowInfoOutput.finderResult,0x0000); sprintf(AlertString,"40/No open window.\rFinder Result = $%x\rError - %s/^OK", tellFinderGetWindowInfoOutput.finderResult, ErrorString); AlertWindow (0x0000,0L,AlertString); } } tellFinderRemoveFromExtrasProc () { tellFinderRemoveFromExtrasOut tellFinderRemoveFromExtrasOutput; static char NoneLeftAlertString[175]; if (menuItemIndex > 0 && menuItemIndex <= MAXNUMMENUITEMS) { SendRequest (tellFinderRemoveFromExtras,0x8001,finderTarget,(long)menuItemID[menuItemIndex-1],(long)&tellFinderRemoveFromExtrasOutput); CheckError(tellFinderRemoveFromExtrasOutput.finderResult,0x0000); sprintf(AlertString,"40/Request Code = tellFinderRemoveFromExtras\rrecvCount = $%x\rResult Code = $%x\rMenuItem ID Removed = $%x\rError - %s/^OK", tellFinderRemoveFromExtrasOutput.recvCount, tellFinderRemoveFromExtrasOutput.finderResult, menuItemID[menuItemIndex-1], ErrorString); AlertWindow (0x0000,0L,AlertString); return --menuItemIndex; } else { sprintf(NoneLeftAlertString,"42/You have deleted all FinderXDA menuItems. This tool will not allow you to delete any other Extras Menu menu items./^OK"); AlertWindow (0x0000,0L,NoneLeftAlertString); } } tellFinderSpecialPreferencesProc () { tellFinderSpecialPreferencesIn tellFinderSpecialPreferencesInput; tellFinderSpecialPreferencesOut tellFinderSpecialPreferencesOutput; word ButtonSelected; sprintf(AlertString,"40/Choose the way you want to send tellFinderSpecialPreferences./^dragHDtoTrash/Don't dragHDtoTrash"); ButtonSelected = AlertWindow (0x0000,0L,AlertString); if (ButtonSelected == 0) { tellFinderSpecialPreferencesInput.dragHDtoTrash = 0x0001; SendRequest (tellFinderSpecialPreferences,0x8001,finderTarget,&tellFinderSpecialPreferencesInput,(long)&tellFinderSpecialPreferencesOutput); CheckError(tellFinderSpecialPreferencesOutput.finderResult,0x0000); sprintf(AlertString,"40/Request Code = tellFinderSpecialPreferences\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK", tellFinderSpecialPreferencesOutput.recvCount, tellFinderSpecialPreferencesOutput.finderResult, ErrorString); AlertWindow (0x0000,0L,AlertString); } else if (ButtonSelected == 1) { tellFinderSpecialPreferencesInput.dragHDtoTrash = 0x0000; SendRequest (tellFinderSpecialPreferences,0x8001,finderTarget,&tellFinderSpecialPreferencesInput,(long)&tellFinderSpecialPreferencesOutput); CheckError(tellFinderSpecialPreferencesOutput.finderResult,0x0000); sprintf(AlertString,"40/Request Code = tellFinderSpecialPreferences\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK", tellFinderSpecialPreferencesOutput.recvCount, tellFinderSpecialPreferencesOutput.finderResult, ErrorString); AlertWindow (0x0000,0L,AlertString); } } HelpWindowProc() { if (HelpWindPtr == 0) { HelpWindPtr = NewWindow (&HelpWindParams); if(_toolErr) CheckError(_toolErr,0x0001); else { SetUpHelpNDASysWindRec(); SetSysWindow(HelpWindPtr); HelpAuxWindRecPtr = (AuxWindInfoPtr)(GetAuxWindInfo(HelpWindPtr)); HelpAuxWindRecPtr -> NDASysWindPtr = (Ptr)&HelpNDASysWindRec; HelpCtlHandle = NewControl2(HelpWindPtr,0x0002,(long)HelpEditTextControlID); if(_toolErr) CheckError(_toolErr,0x0001); } } else SelectWindow (HelpWindPtr); } CloseFromNDA() { ResourceShutDown(); CloseFinderXDA(); } /* below this point in the program, we must be very careful about * managing the contents of the data bank register. We must save * it first, alter it to point to the ~globals segment (SaveDB() does this) * and then when we are done, caL RestoreDB(). * Access to arrays and automatic (i.e. local) variables will work correctly * with ANY value of data bank register. */ /************************************************************************************************/ /* The DA Close procedure */ pascal void CloseFinderXDA() { int dbr; GrafPortPtr p; dbr = SaveDB(); p = (GrafPortPtr)GetDeskGlobal(0); if(p == MatchWindPtr) { CloseWindow(MatchWindPtr); MatchWindPtr = 0; } else if(p == HelpWindPtr) { CloseWindow(HelpWindPtr); HelpWindPtr = 0; } else if(p == DebugInfoWindPtr) { CloseWindow(DebugInfoWindPtr); DebugInfoWindPtr = 0; } else if(p == GetSelectedIconsWindPtr) { CloseWindow(GetSelectedIconsWindPtr); GetSelectedIconsWindPtr = 0; } else if(p == GetWindowIconsWindPtr) { CloseWindow(GetWindowIconsWindPtr); GetWindowIconsWindPtr = 0; } else if(p == FinderXDAWindPtr) { DisposeIdleProc(); if(tellFinderGetSelectedIconsOutput.stringListHandle != NIL) { DisposeHandle((long)tellFinderGetSelectedIconsOutput.stringListHandle & ~0x80000000); if(_toolErr) CheckError(_toolErr,0x0001); tellFinderGetSelectedIconsOutput.stringListHandle = NIL; } CloseIfOpen(&DebugInfoWindPtr); CloseIfOpen(&GetSelectedIconsWindPtr); CloseIfOpen(&GetWindowIconsWindPtr); CloseIfOpen(&HelpWindPtr); CloseWindow(FinderXDAWindPtr); FinderXDAWindPtr = 0; if (TEStarted) { TEShutDown(); DisposeHandle(TEZeroPageHndl); if(_toolErr) CheckError(_toolErr,0x0001); TEStarted = 0; } if (FMStarted) { FMShutDown(); DisposeHandle(FMZeroPageHndl); if(_toolErr) CheckError(_toolErr,0x0001); FMStarted = 0; } finderSaysIdleFlag = 0; OpenFlag = 0; ResourceShutDown(); } RestoreDB(dbr); } /************************************************************************************************/ /* The DA Open procedure */ pascal GrafPortPtr OpenFinderXDA() { GrafPortPtr p; int dbr; LevelRecGS oldSysFileLevel; LevelRecGS newSysFileLevel; SysPrefsRecGS oldSysPrefs; SysPrefsRecGS newSysPrefs; word App_ID; word rFile_ID; pointer PathNamePtr; tellFinderAreYouThereOut tellFinderAreYouThereOutput; dbr = SaveDB(); OpenFlag = 0; FinderXDAWindPtr = NIL; SendRequest (askFinderAreYouThere,0x8001,finderTarget,0L,&tellFinderAreYouThereOutput); if (_toolErr) { AlertWindow (0x0000,0L,"42/The Finder is not running. The DA window will not be opened./^OK"); p = NIL; } else { myID = MMStartUp(); LoadOneTool(0x001b,0x0100); /* Load the Font Manager */ if(_toolErr) CheckError(_toolErr,0x0001); else { if ( ! FMStatus() ) { FMZeroPageHndl = NewHandle(0x100L,myID,0xc005,0L); if(FMZeroPageHndl == NIL) { sprintf(AlertString,"42/NewHandle failed for FMZeroPageHndl./^OK"); AlertWindow (0x0000,NULL,AlertString); } else { FMStartUp(myID,(Word)*FMZeroPageHndl); FMStarted = TRUE; } } LoadOneTool(0x0022,0x0100); if(_toolErr) CheckError(_toolErr,0x0001); else { if ( ! TEStatus() ) /* Is TextEdit not started */ { TEZeroPageHndl = NewHandle(0x100L,myID,0xc005,0L); if(TEZeroPageHndl == NIL) { sprintf(AlertString,"42/NewHandle failed for TEZeroPageHndl./^OK"); AlertWindow (0x0000,NULL,AlertString); } else { TEStartUp(myID,(Word)*TEZeroPageHndl); /* Start it */ TEStarted = TRUE; /* Set the flag for Close routine */ } } App_ID = GetCurResourceApp(); /* Get the current application ID and save */ NDA_ID = MMStartUp(); /* Get the DA ID and save */ ResourceStartUp(NDA_ID); /* Start the resource manager with DA ID */ PathNamePtr = LGetPathname2(NDA_ID,0x0001); /* Get the address of the DA pathname */ oldSysFileLevel.pCount = 0x0002; /* Set-up pBlock for GetLevelGS calll */ oldSysFileLevel.levelMode = 0x0000; GetLevelGS(&oldSysFileLevel); /* Get the current SysFileLevel */ newSysFileLevel.pCount = 0x0002; newSysFileLevel.level = 0x0080; /* this protects the resource from being closed */ newSysFileLevel.levelMode = 0x0000; SetLevelGS(&newSysFileLevel); /* Change the file level to protect the resource fork from a close on refernce num 0 */ oldSysPrefs.pCount = 0x0001; GetSysPrefsGS(&oldSysPrefs); /* Get the current SysPrefs */ newSysPrefs.pCount = 0x0001; newSysPrefs.preferences = (oldSysPrefs.preferences & 0x1fff) | 0x8000; /* Set new SysPrefs field to new value, will prompt user to insert disk if volume not found */ SetSysPrefsGS(&newSysPrefs); rFile_ID = OpenResourceFile(0x0001,0L,PathNamePtr); /* Finally open the DA resource file */ if(_toolErr) CheckError(_toolErr,0x0001); else /* We go here if no error */ { SetCurResourceApp(App_ID); /* Reset resource app ID back original value */ FinderXDAWindPtr = NewWindow(&FinderXDAWindParams); /* Create the DA window */ if(_toolErr) CheckError(_toolErr,0x0001); else { SetSysWindow(FinderXDAWindPtr); /* Set the DA window as the System Window */ OpenFlag = 1; NewControl2(FinderXDAWindPtr,3,FinderXDACtlList); /* Create the DA controls */ if(_toolErr) CheckError(_toolErr,0x0001); } } SetSysPrefsGS(&oldSysPrefs); /* Reset SysPrefs back original value */ SetLevelGS(&oldSysFileLevel); /* Reset file level back original value */ } } } quitflag = 0; /* Set the quit flag */ p = FinderXDAWindPtr; RestoreDB(dbr); return p; /* WARNING: at this point, DB is at a random value */ } /* but access to p wiL work OK; doesn't use DBR */ /************************************************************************************************/ /* The DA Action procedure */ ActionFinderXDA(a_reg, x_reg, y_reg) Word a_reg, x_reg, y_reg; { int dbr; Word theEvent; WmTaskRec myTaskRec; Word MItemSelectedID; int ActionCode; EventRecordPtr EventP; dbr = SaveDB(); if(! quitflag) { ActionCode = a_reg; EventP = (EventRecordPtr) ( ( (Long)y_reg << 16 ) + x_reg ); switch(ActionCode) { case eventAction: if (EventP->what == wInContent) AlertWindow(0,NULL,"20|wInContent passed in wmWhat.|^Continue"); myTaskRec.what = EventP->what; myTaskRec.message = EventP->message; myTaskRec.where = EventP->where; myTaskRec.when = EventP->when; myTaskRec.modifiers = EventP->modifiers; myTaskRec.wmTaskMask = 0x1fffffL; theEvent = TaskMasterDA(0,&myTaskRec); switch(theEvent) { case wInGoAway: if (myTaskRec.wmTaskData == (long)FinderXDAWindPtr) { quitflag = 1; } break; case wInControl: if (myTaskRec.wmTaskData == (long)FinderXDAWindPtr) { if (myTaskRec.wmTaskData4 == 0x00000100L) { switch (GetCtlValue(myTaskRec.wmTaskData2)) { case 0x0100: AcceptRequests ("\pAppleComputer~FinderXDAHello~",MMStartUp(),HelloRequestProc); break; case 0x0101: AcceptRequests ("\pAppleComputer~FinderXDAGoodbye~",MMStartUp(),GoodbyeRequestProc); break; case 0x0102: AcceptRequests ("\pAppleComputer~FinderXDASelectionChanged~",MMStartUp(),SelectionChangedRequestProc); break; case 0x0103: AcceptRequests ("\pAppleComputer~FinderXDAMItemSelected~",MMStartUp(),MItemSelectedRequestProc); break; case 0x0104: AcceptRequests ("\pAppleComputer~FinderXDABeforeOpen~",MMStartUp(),BeforeOpenRequestProc); break; case 0x0105: AcceptRequests ("\pAppleComputer~FinderXDAOpenFailed~",MMStartUp(),OpenFailedRequestProc); break; case 0x0106: AcceptRequests ("\pAppleComputer~FinderXDABeforeCopy~",MMStartUp(),BeforeCopyRequestProc); break; case 0x0107: AcceptRequests ("\pAppleComputer~FinderXDAIdle~",MMStartUp(),IdleRequestProc); break; case 0x0108: AcceptRequests ("\pAppleComputer~FinderXDAExtrasChosen~",MMStartUp(),ExtrasChosenRequestProc); break; case 0x0109: AcceptRequests ("\pAppleComputer~FinderXDABeforeRename~",MMStartUp(),BeforeRenameRequestProc); break; case 0x010A: AcceptRequests ("\pAppleComputer~FinderXDAKeyHit~",MMStartUp(),KeyHitRequestProc); break; case 0x010B: /* Stop receiving requests */ RemoveRequestProcs (); break; } } else if (myTaskRec.wmTaskData4 == 0x00000800L) { switch (GetCtlValue(myTaskRec.wmTaskData2)) { case 0x8000: tellFinderGetDebugInfoProc (); break; case 0x8001: tellFinderAreYouThereProc (); break; case 0x8002: tellFinderOpenWindowProc (); break; case 0x8003: tellFinderCloseWindowProc (); break; case 0x8004: tellFinderGetSelectedIconsProc (); break; case 0x8005: tellFinderSetSelectedIconsProc (); break; case 0x8006: tellFinderLaunchThis_Ap_Proc (); break; case 0x807A: tellFinderShutDown_PowerOff_Proc (); break; case 0x807B: tellFinderShutDown_Restart_Proc (); break; case 0x807C: tellFinderShutDown_QuitFinder_Proc (); break; case 0x800A: tellFinderMatchFileToIconProc(); break; case 0x800B: tellFinderAddBundleProc (); break; case 0x800C: tellFinderAboutChangeProc (); break; case 0x800D: tellFinderCheckDatabaseProc (); break; case 0x800F: tellFinderAddToExtrasProc (); break; case 0x8011: tellFinderIdleHowLongProc (); break; case 0x8012: tellFinderGetWindowIconsProc (); break; case 0x8013: tellFinderGetWindowInfoProc (); break; case 0x8014: tellFinderRemoveFromExtrasProc (); break; case 0x8015: tellFinderSpecialPreferencesProc (); break; } } else if (myTaskRec.wmTaskData4 == 0x00000900L) { MItemSelectedID = GetCtlValue(myTaskRec.wmTaskData2); tellFinderMItemSelectedProc(MItemSelectedID); } else if (myTaskRec.wmTaskData4 == 0x0000800EL) { tellFinderColorSelectionProc(); } else if (myTaskRec.wmTaskData4 == 0x00000300L) { HelpWindowProc(); } break; } else if (myTaskRec.wmTaskData == (long)MatchWindPtr) { if (myTaskRec.wmTaskData4 == 0x00002000L) { DoTheMatchProc(); } } break; } break; case runAction: break; case cursorAction: break; case undoAction: break; case cutAction: TECut(NULL); break; case copyAction: TECopy(NULL); break; case pasteAction: TEPaste(NULL); break; case clearAction: TEClear(NULL); break; default: break; } if(quitflag) { DisposeIdleProc(); CloseNDAByWinPtr(FinderXDAWindPtr); if(_toolErr) CheckError(_toolErr,0x0001); } } RestoreDB(dbr); } /************************************************************************************************/ /* The DA Init procedure */ InitFinderXDA() { unsigned oldDB = SaveDB(); menuItemIndex = 0; AcceptRequests ("\pAppleComputer~FinderXDAInitHello~",MMStartUp(),InitHelloRequestProc); RestoreDB(oldDB); }